package com.example.demo.service;

import com.example.demo.dao.CatDao;
import com.example.demo.entity.Cat;
import com.example.demo.repository.CatRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Choisaaaa on 2018/6/6.
 */
@Service
public class CatService {
    @Resource
    private CatRepository catRepository;

    @Resource
    private CatDao catDao;

    @Transactional
    public void save(Cat cat){
        catRepository.save(cat);
    }
    public void delete(int id){
        catRepository.deleteById(id);
    }

    public void getAll(){
        catRepository.findAll();
    }

    public Cat findByCatName(String CatName){
        return catRepository.findByCatName(CatName);
    }
    public Cat findByCatName2(String CatName){
        return catRepository.findByCatName2(CatName);
    }

    public Cat selectByCatName(String catName){
        return catDao.selectByCatName(catName);
    }

}
